package com.jeesite.modules.sys.utils;

import com.jeesite.modules.ajz.entity.AjzCheck;

import java.io.*;
import java.util.List;

public class AjzUtils {

    //深度复制
    public static <T> List<T> deepCopy(List<T> src) throws IOException, ClassNotFoundException {
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(byteOut);
        out.writeObject(src);

        ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
        ObjectInputStream in = new ObjectInputStream(byteIn);
        @SuppressWarnings("unchecked")
        List<T> dest = (List<T>) in.readObject();
        return dest;
    }

    //过滤掉不要的隐患问题项
    public static List<AjzCheck> filter(List<AjzCheck> list, String num){
        boolean flag =true;
        for(int i=list.size()-1;i>=0;i--){
            if(!num.equals(list.get(i).getCheckStatus())){
                list.remove(i);
                list.add(i,null);
            }
            System.out.println(list.get(i));
            //如果list中有存在不为null的值
            if(list.get(i)!=null){
                flag = false;
            }
        }

        if(flag){
            list=null;
        }
        return list;
    }

}
